//
//  SRReader.h
//  SunriseReaderDemo
//
//  Created by 田宇 on 2024/11/26.
//  Copyright © 2024 Chenfan. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <SRIDCardReader/SRIDCardReader.h>
#import "SRIDCardModel.h"
#import "SRIDCardGenerator.h"
#import "ReadCertErrorInfo.h"
#import "SRReaderLogInfo.h"

NS_ASSUME_NONNULL_BEGIN

typedef void (^CompletionHandler)(NSDictionary *result, NSURLResponse *response, NSError *error);

@protocol SRReaderControllerDelegate <NSObject>

//读取成功回调 处理过后的身份信息，有正反图片
- (void)readSuccessWithDic:(NSDictionary *)resultDic;
//读取失败回调
- (void)readFail:(CBPeripheral *)peripheral withError:(NSError *)error;
//读取成功回调,未处理的原始读卡信息
- (void)readSuccessWithJsonStr:(NSString *)jsonStr;
@end


@interface SRReaderController : NSObject

@property (weak,nonatomic) id <SRReaderControllerDelegate> delegate;
//读取到的身份证信息
@property (readonly, nonatomic) SRIDCardModel *IDCardModel;
//身份证正反照片
@property (readonly, strong, nonatomic) UIImage *IDCardImg;
@property (readonly, strong, nonatomic) NSString *IDCardImgBase64;

//身份证背面图片,国徽
@property (readonly, strong, nonatomic) UIImage *IDCardBackImg;
@property (readonly, strong, nonatomic) NSString *IDCardBackImgBase64;

//身份证正面图片,信息
@property (readonly, strong, nonatomic) UIImage *IDCardFrontImg;
@property (readonly, strong, nonatomic) NSString *IDCardFrontImgBase64;

//读卡开始时间yyyy-MM-dd HH:mm:ss
@property (readonly) NSString* startTime;
//读卡结束时间yyyy-MM-dd HH:mm:ss
@property (readonly) NSString* endTime;
//读卡耗时
@property (readonly) NSString* costTime;

@property (strong, nonatomic) SRReaderLogInfo *logInfo;
//操作结果码，操作结果明细 0成功，1失败
@property (readonly, strong, nonatomic) NSString *opResultCode;
@property (readonly, strong, nonatomic) NSString *opResultDetail;
//森锐返回异常结果编号
@property (readonly, strong, nonatomic) NSString *resultTypeCode;
//结果类型名称
@property (readonly, strong, nonatomic) NSString *resultTypeName;
//结果明细
@property (readonly, strong, nonatomic) NSString *resultTypeDetail;
//服务器地址 默认测试 http://42.100.35.125:39600/npl-sdk-service/
@property (readonly, strong, nonatomic) NSString *serverAddress;
//初始化读卡器
- (id)initWithReader:(SRIDCardReader *)reader manager:(CBCentralManager *)manager;

//读卡操作，当前选中的蓝牙设备
// @param 上游参数


- (void)readIDCardWithPeripheral:(CBPeripheral *)Peripheral parameters:(NSDictionary *)param;

//设置服务器地址
- (void)setServer:(NSString *)serverAddress;

//上传读卡日志 /api/device/recordSdkLog
- (void)recordSdkLogWithParameters:(NSDictionary *)parameters
                   completionBlock:(CompletionHandler)completion;

@end

NS_ASSUME_NONNULL_END
